<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right" class="tit">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-input
        placeholder="请输入内容"
        v-model="query"
        class="input-with-select inp"
      >
        <el-button
          slot="append"
          icon="el-icon-search"
          @click="onSearch"
        ></el-button>
      </el-input>

      <el-table border :data="ordersData" style="width: 100%">
        <el-table-column label="#" type="index" width="47"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号" width="318">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="130">
        </el-table-column>
        <el-table-column label="是否支付" width="130">
          <el-tag type="danger">未支付</el-tag>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货" width="130">
        </el-table-column>
        <el-table-column prop="create_time" label="下单时间" width="180">
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="{ row }">
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              @click="address(row.order_id)"
            ></el-button>
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[2, 4, 6, 8]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="ordersTotal"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  name: "ordersInfo",
  components: {},
  props: {},
  data() {
    return {
      currentPage: 0,
      orders: {
        query: null, //	查询参数	可以为空
        pagenum: 1, //	当前页码	不能为空
        pagesize: 2, //	每页显示条数	不能为空
        user_id: null, //	用户 ID	可以为空
        pay_status: null, //	支付状态	可以为空
        is_send: null, //是否发货	可以为空
        order_fapiao_title: null, //	['个人','公司']	可以为空
        order_fapiao_company: null, //	公司名称	可以为空
        order_fapiao_content: null, //	发票内容	可以为空
        consignee_addr: null, //发货地址	可以为空
      },
      ordersData: [],
      ordersTotal: 0,
      query: "",
    };
  },
  computed: {},
  watch: {},
  created() {
    this.getOrdersData();
  },
  methods: {
    ...mapActions(["orders/getOrders"]),
    handleSizeChange(val) {
      this.orders.pagesize = val;
      this.getOrdersData();
    },
    handleCurrentChange(val) {
      this.orders.pagenum = val;
      this.getOrdersData();
    },
    async getOrdersData() {
      await this["orders/getOrders"](this.orders);
      this.ordersData = this.$store.getters.ordersData;
      this.ordersTotal = this.$store.getters.ordersTotal;
    },
    onSearch() {
      // console.log("1");
      this.orders.query = this.query;
      this.getOrdersData();
    },
  },
};
</script>
<style scoped>
.tit {
  font-size: 14px;
}
.inp {
  width: 368px;
  padding: 0px 30px 0px 15px;
}
</style>
